package br.projeto.tarefas.bean;
 
import java.io.IOException;
import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

//import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;

import br.projeto.tarefas.pojo.UploadGravaBanco;
 
@ViewScoped
@ManagedBean(name = "uploadBean")
public class UploadPlanilhaBEAN implements Serializable {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	UploadGravaBanco up = new UploadGravaBanco();
    private UploadedFile file;
    public String pastaXLS = "C:\\SistemaTarefas\\Planilhas para Upload\\";
 
    public UploadedFile getFile() {
       return file;
    }
 
    public void setFile(UploadedFile file) {
        this.file = file;
    }
     
    // Chamar Code para fazer a leitura da planilha 
    public void upload() throws IOException {
        if(file != null) {
        	System.out.print("Entrou no metodo");
        	up.uploadxml(pastaXLS + getFile());
            FacesMessage message = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
            FacesContext.getCurrentInstance().addMessage(null, message);
        }
        System.out.print("Entrou no metodo ma file vazio");
    	
    }
}

